package com.zeroxml.cms.dao.impl;

import com.zeroxml.cms.bo.Link;
import com.zeroxml.cms.dao.ILinkDAO;
import com.wyvoid.core.persistent.hibernate.HibernateDAO;
import com.wyvoid.core.persistent.hibernate.HibernatePage;

import java.util.List;

/**
 * User: cjp
 * Date: 2007-9-22
 * Time: 11:57:01
 */
public class LinkDAO extends HibernateDAO<Link> implements ILinkDAO {
    public List<Link> getLinks(long catalogId) {
        String hql="from Link ";
        if(catalogId>0){
            hql+=" where catalogId="+catalogId;
        }
        hql+=" order by orders desc";
        return doQueryList(hql,true);
    }

    public HibernatePage<Link> getAllLinks(int curPage,int pageSize) {
        String hql="from Link order by orders desc";
        return doQuery(hql,true,curPage,pageSize);
    }

    public List<Link> getIndexLinks(int i) {
        String hql="from Link where showOnIndex=true";
        return doQueryLimitList(hql,true,i);
    }
}
